using System;
using System.Collections.Generic;
using Agatha.Common;
using Source.Common;
using Source.ServiceLayer;

namespace Source.ServiceLayer
{
    public interface IServerSideUserManager : IUserManager
    {
        Visit GetVisit();
        bool HasVisit();
    }

    public class UserManager : IServerSideUserManager
    {
        [ThreadStatic]
        private static Visit visit;

        private readonly IOlaMembershipProvider membershipProvider;

        public UserManager(IOlaMembershipProvider membershipProvider)
        {
            this.membershipProvider = membershipProvider;
        }

        public IUser GetCurrentUserInfo()
        {
            return visit.User;
        }

        public void StoreCurrentVisitInfo(Visit visitToStore)
        {
            visit = visitToStore;   
        }

        public bool HasVisit()
        {
            return visit != null;
        }

        public Visit GetVisit()
        {
            return visit;
        }
    }
}